using System;
using System.Linq;
using System.Windows;
using System.Windows.Input;
using DotNet.Utilities;
using WPFPractice.Const;
using WPFPractice.Dialogs;
using WPFPractice.Models;
using WPFPractice.Utils;
using WPFPractice.ViewModels;
using WPFTemplateLib.WpfHelpers;

namespace WPFPractice.Windows
{
	/// <summary>
	/// WinWindow.xaml 的交互逻辑
	/// </summary>
	public partial class WinWindow : Window
	{
		public WinWindow()
		{
			InitializeComponent();
			DataContext = new WindowViewModel();
		}
	}
}

namespace WPFPractice.ViewModels
{
	public class WindowViewModel : MyViewModelBase
	{
		#region 绑定

		public EditTypeEnum EditType { get; set; } = EditTypeEnum.Show;

		#endregion

		#region 命令

		#region [命令] 弹出蒙板弹窗
		private ICommand _ShowMaskDialogCmd;
		public ICommand ShowMaskDialogCmd => _ShowMaskDialogCmd ??= new RelayCommand<Window>(ExecuteShowMaskDialogCmd);
		private void ExecuteShowMaskDialogCmd(Window win)
		{
			win ??= Application.Current.MainWindow;
			new MaskDialog(win).ShowDialog();
		}
		#endregion

		#region [命令] 弹出选择枚举弹窗（显示描述）
		private RelayCommand _ShowEnumDescriptionItemsDialogCmd;
		public RelayCommand ShowEnumDescriptionItemsDialogCmd => _ShowEnumDescriptionItemsDialogCmd ??= new RelayCommand(ExecuteShowEnumDescribeItemsDialogCmd);
		private void ExecuteShowEnumDescribeItemsDialogCmd()
		{
			var options = EnumExtension.GetEnumList<EditTypeEnum>().Cast<Enum>();
			var dialog = new SelectEnumItemDialog("请选择枚举项（显示枚举描述）", options, EditType);
			if(dialog.ShowDialogWithMask() == true)
			{
				EditType = (EditTypeEnum)dialog.SelectedItem;
			}
		}
		#endregion

		#region [命令] 弹出选择枚举弹窗（显示自定义文本）
		private RelayCommand _ShowEnumCustomTextItemsDialogCmd;
		public RelayCommand ShowEnumCustomTextItemsDialogCmd => _ShowEnumCustomTextItemsDialogCmd ??= new RelayCommand(ExecuteShowEnumCustomTextItemsDialogCmd);
		private void ExecuteShowEnumCustomTextItemsDialogCmd()
		{
			var options = EnumExtension.GetEnumList<EditTypeEnum>().Cast<Enum>();
			var dialog = new SelectEnumCustomTextDialog("请选择枚举项（显示自定义文本）", options, EditType, KeyValuePairStrs.EDIT_TYPE_SHOW_TEXT);
			if(dialog.ShowDialogWithMask() == true)
			{
				EditType = (EditTypeEnum)dialog.SelectedItem;
			}
		}
		#endregion

		#endregion
	}
}
